package com.huiyeji.sort;

import com.huiyeji.sort.utils.OrderUtil;

import java.util.Comparator;

public class SortedComparator<T> implements Comparator<T> {

    @Override
    public int compare(T o1, T o2) {
        int order1 = OrderUtil.getOrder(o1);
        int order2 = OrderUtil.getOrder(o2);
        int res = (order1 < 0 ? Integer.MAX_VALUE : order1) - (order2 < 0 ? Integer.MAX_VALUE : order2);
        return res == 0 ? 1 : res;
    }
}
